//字符串替换
import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param str string字符串 原串
     * @param arg char字符型一维数组 需替换数组
     * @return string字符串
     */
    public String formatString (String s, char[] arg) {
        // write code here
        if (arg == null || arg.length == 0) {
            return s;
        }
        StringBuilder str = new StringBuilder();
        int i = 0;
        if (s == null || s.length() == 0) {

            while (i < arg.length) {
                str.append(arg[i++]);
            }
            return str.toString();
        }
        int len = s.length();
        for (int j = 0; j < len; j++) {
            char c = s.charAt(j);
            if (c == '%' && j != len-1 && s.charAt(j+1) == 's') {
                j++;
                str.append(arg[i++]);
            } else {
                str.append(c);
            }
        }
        while (i < arg.length) {
            str.append(arg[i++]);
        }
        return str.toString();
    }
}
//神奇数
import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static Set<Integer> contains;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        contains = new HashSet<>();
        for (int i = 10; i < 100; i++) {
            if (fun(i)) {
                contains.add(i);
            }
        }
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            if (b < 10) {
                System.out.println(0);
                continue;
            }
            int count = 0;
            List<Integer> list = new ArrayList<>();
            for (a = (a < 10 ? 10 : a); a <= b; a++) {
                int tmp = a;
                while (tmp != 0) {
                    list.add(tmp%10);
                    tmp /= 10;
                }
                int len = list.size();
                count += fun1(list, len);
                list.clear();
            }
            System.out.println(count);
        }
    }

    public static int fun1(List<Integer> list, int len) {
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < len; j++) {
                if (j == i) {
                    continue;
                }
                if (contains.contains(list.get(i)*10+list.get(j))) {
                    return 1;
                }
            }
        }
        return 0;
    }

    public static boolean fun(int a) {
        for (int i = 2; i < a/2; i++) {
            if (a % i == 0) {
                return false;
            }
        }
        return true;
    }
}
//DNA序列
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str = in.next();
            char[] arr = str.toCharArray();
            int b = in.nextInt();
            int len = arr.length;
            int l = 0;
            int r = 0;
            int count = 0;
            int[] ret = new int[2];
            int maxCount = 0;
            while (r < len) {
                if (arr[r] == 'C' || arr[r] == 'G') {
                    count++;
                }
                if (r-l+1 == b) {
                    if (count > maxCount) {
                        ret[0] = l;
                        ret[1] = r;
                        maxCount = count;
                    } 
                    if (arr[l] == 'C' || arr[l] == 'G') {
                        count--;
                    }
                    l++;
                }
                r++;
            }
            System.out.println(str.substring(ret[0], ret[1]+1));
        }
    }
}